
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>帐号设置</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="keywords" content="fly,layui,前端社区">
  <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
  <link rel="stylesheet" href="../../res/layui/css/layui.css">
  <link rel="stylesheet" href="../../res/css/global.css">
  <script src="/js/jquery.min.js"></script>
  <script src="/js/common.variate.js"></script>
  <script src="/js/common.method.js"></script>
  <link rel="stylesheet" href="/css/header.css">
</head>
<body>

<div class="fly-header layui-bg-black">
  <div class="layui-container">
    <a class="fly-logo" href="/">
      <img src="/images/logo.png" alt="layui" style="width: 105px;">
    </a>
    <ul class="layui-nav fly-nav-user" id="tabYe">

    </ul>
  </div>
</div>

<div class="layui-container fly-marginTop fly-user-main">
  <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
    <li class="layui-nav-item">
      <a href="mydoc.html">
        <i class="layui-icon">&#xe612;</i>
        我的文档
      </a>
    </li>
    <li class="layui-nav-item layui-this">
      <a href="myinfo.html">
        <i class="layui-icon">&#xe620;</i>
        基本设置
      </a>
    </li>
  </ul>

  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>
  
  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>
  
  
  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title" id="LAY_mine">
        <li class="layui-this" lay-id="info">我的资料</li>
        <li lay-id="pass">密码</li>
      </ul>
      <div class="layui-tab-content" style="padding: 20px 0;">

        <div class="layui-form layui-form-pane layui-tab-item  layui-show">
          <div class="layui-form-item">
            <label for="L_nowpass" class="layui-form-label">用户姓名</label>
            <div class="layui-input-inline">
              <input type="text" id="L_name" name="nowpass" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <button class="layui-btn" key="set-mine" lay-filter="*" onclick="updateName()">确认修改</button>
          </div>
        </div>
          <div class="layui-form layui-form-pane layui-tab-item">
              <div class="layui-form-item">
                <label for="L_nowpass" class="layui-form-label">当前密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_nowpass" name="nowpass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_pass" name="pass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <!--<div class="layui-form-mid layui-word-aux">6到16个字符</div>-->
              </div>
              <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_repass" name="repass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <button class="layui-btn" key="set-mine" lay-filter="*" onclick="updatePassword()">确认修改</button>
              </div>
          </div>


        </div>

      </div>
    </div>
  </div>
</div>

<div class="fly-footer">
  <p> 2018 &copy; <a href="https://gitee.com/chaofan2685_admin" target="_blank">炒饭 出品</a></p>
  <p>
    <a href="http://www.lishiots.com/" target="_blank">力石科技</a>
    <a href="tencent://message/?uin=894195915&Site=http://vps.shuidazhe.com&Menu=yes">交个朋友</a>
    <a href=mailto:chaofan2685@qq.com>问题反馈</a>
  </p>
</div>

<script src="../../res/layui/layui.all.js"></script>
<script>
    checkLogin2();
layui.cache.page = 'user';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: '../../res/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  version: "2.0.0"
  ,base: '../../res/mods/'
}).extend({
  fly: 'index'
}).use('fly');

function updateName() {
    var name = $("#L_name").val();
    if (isEmpty(name)){
        layer.msg("姓名不能为空！",{anim: 6});
        return false;
    }
    $.ajax({
        type: "POST",
        url: "/api/user/updateName",
        data: {name:name},
        dataType: "json",
        success: function(data){
            if (data.code == "8200"){
                location.reload();
            }else {
                layer.alert(data.message, {icon: 2});
            }
        }
    });
}

function updatePassword() {
    var oldPassword = $("#L_nowpass").val();
    var newPassword = $("#L_pass").val();
    var rePassword = $("#L_repass").val();
    if (isEmpty(oldPassword) || isEmpty(newPassword) || isEmpty(rePassword)){
        layer.msg("必填项不能为空！",{anim: 6});
        return false;
    }
    if (oldPassword == newPassword){
        layer.msg("新旧密码不能一致！",{anim: 6});
        return false;
    }
    if (newPassword == rePassword){
        $.ajax({
            type: "POST",
            url: "/api/user/updatePassword",
            data: {oldPassword:oldPassword,newPassword:newPassword},
            dataType: "json",
            success: function(data){
                if (data.code == "8200"){
                    layer.msg('修改成功！', {
                        time: 0 //不自动关闭
                        ,btn: ['确定']
                        ,yes: function(index){
                            layer.close(index);
                            logout("/login.html");
                        }
                    });
                }else {
                    layer.alert(data.message, {icon: 2});
                }
            }
        });
    }else {
        layer.msg("两次输入密码不一致！",{anim: 6});
    }

}
</script>

</body>
</html>